package cn.xyy.system.api;

import cn.xyy.system.service.LogService;
import cn.xyy.system.service.OnlineUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.xyy.common.domain.mvc.R;
import cn.xyy.common.domain.system.log.SysLog;
import cn.xyy.common.domain.system.log.SysLogVO;
import cn.xyy.common.domain.system.online.OnlineUserFilter;

/**
 * 日志接口
 * 
 * @author xyy
 *
 */
@RestController
@RequestMapping(value = "/rest/monitor")
public class MonitorRest {
	@Autowired
	private LogService logService;
	@Autowired
	private OnlineUserService onlineUserService;

	@RequestMapping(value = "/blog/getListPage", method = RequestMethod.GET)
	public R getListPage(SysLogVO vo) {
		return R.ok(logService.getListPage(vo));
	}

	@RequestMapping(value = "/blog/save", method = RequestMethod.POST)
	public R save(@RequestBody SysLog log) {
		logService.save(log);
		return R.ok();
	}

	@RequestMapping(value = "/onlineUser/getListPage", method = RequestMethod.GET)
	public R onlineUser(OnlineUserFilter filter) {
		return R.ok(onlineUserService.onlineUser(filter));
	}

	@RequestMapping(value = "/onlineUser/kickout", method = RequestMethod.GET)
	public R kickout(@RequestParam("token") String token) {
		onlineUserService.kickoutByToken(token);
		return R.ok();
	}

}
